﻿using System;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using HRM.HRMServiceProxy;
using WeifenLuo.WinFormsUI.Docking;

namespace HRM
{
    public partial class frmSalaryFundList : DockContent
    {
        int pageSize = UIParamater.pageSize;
        int currPage = 0;
        int itemCount = 0;
        int totalPage = 0;
        int SalaryFundID;
        bool _loadedData = true;
        int _month = DateTime.Now.Month;
        int _year = DateTime.Now.Year;
        ParameterClient wcfParameter;
        SalaryFundClient _wcfSalaryFund;
        SalaryFundInfo _SalaryFundInfo;
        MainServiceClient wcfMainService;
        SalaryClient _wcfSalary;
        string _date;

        decimal _SocialInc;
        decimal _MedicalInc; RoleRightInfo listRole;
        public frmSalaryFundList()
        {
            InitializeComponent();
            LoadLanguage();
            _wcfSalaryFund = Service.SalaryFund();
            listRole = UIParamater.Quyen_DoiChieuQuyBHXH;

            UISetting.LoadMonths(ref cboMonth);
            UISetting.LoadYears(ref cboYear);

            //cboMonth.ComboBox.SelectedValue = Convert.ToUInt32(DateTime.Now.Month);
            //cboYear.ComboBox.SelectedValue = Convert.ToUInt32(DateTime.Now.Year);

            LoadData();
            this.KeyPreview = true;
        }
        void LoadLanguage()
        {
            if (this.Tag != null)
                this.TabText = this.Text = UpdateUI.GetString(this.Tag.ToString());
            UpdateUI.Load_ToolStrip(ref toolStrip1);
        }
        private void LoadData()
        {
            int temptYear;
            if (Int32.TryParse(cboYear.Text, out temptYear))
                _year = temptYear;

            DataSet _ds = _wcfSalaryFund.SalaryFund_GetList(out itemCount, currPage, pageSize, _year,Program.strBranchBHXH);

            PageIndex();

            grid1.Redim(24, 15);
            grid1.FixedRows = 2;

            grid1[0, 0] = new MyHeader(UpdateUI.GetString("quy")); grid1[0, 0].RowSpan = 2;
            //grid1[0, 0].Column.Width = 100;

            grid1[0, 1] = new MyHeader(UpdateUI.GetString("thang")); grid1[0, 1].RowSpan = 2;

            grid1[0, 2] = new MyHeader(UpdateUI.GetString("doichieubhxh")); grid1[0, 2].ColumnSpan = 6;

            grid1[1, 2] = new MyHeader(UpdateUI.GetString("laodong"));

            grid1[1, 3] = new MyHeader(UpdateUI.GetString("tongquyluong"));

            grid1[1, 4] = new MyHeader(UpdateUI.GetString("phaithu"));
            grid1[1, 5] = new MyHeader(UpdateUI.GetString("dieuchinhtang"));
            grid1[1, 6] = new MyHeader(UpdateUI.GetString("dieuchinhgiam"));
            grid1[1, 7] = new MyHeader(UpdateUI.GetString("tongcong"));

            grid1[0, 8] = new MyHeader(UpdateUI.GetString("dathu")); grid1[0, 8].RowSpan = 2;


            grid1[0, 9] = new MyHeader(UpdateUI.GetString("chuyensang")); grid1[0, 9].ColumnSpan = 2;

            grid1[1, 9] = new MyHeader(UpdateUI.GetString("conthua"));
            grid1[1, 10] = new MyHeader(UpdateUI.GetString("thieu"));

            for (int i = 0; i < _ds.Tables[0].Rows.Count; i++)
            {


                // ----------- Define Quarter ----------------------------------------
                int _month = Convert.ToInt32(Convert.ToDateTime(_ds.Tables[0].Rows[i]["SalaryFund_Month"]).ToString("MM"));
                if (_month >= 1 && _month <= 3)
                {
                    grid1[i + 2, 0] = new SourceGrid.Cells.Cell(1, typeof(Int32));

                }
                if (_month > 3 && _month <= 6)
                {
                    grid1[i + 2, 0] = new SourceGrid.Cells.Cell(2, typeof(Int32));

                }
                if (_month > 6 && _month <= 9)
                {
                    grid1[i + 2, 0] = new SourceGrid.Cells.Cell(3, typeof(Int32));

                }
                if (_month > 9 && _month <= 12)
                {
                    grid1[i + 2, 0] = new SourceGrid.Cells.Cell(4, typeof(Int32));

                }

                // -----------------------------------------------------------------
                grid1[i + 2, 1] = new SourceGrid.Cells.Cell(Convert.ToDateTime(_ds.Tables[0].Rows[i]["SalaryFund_Month"]).ToString("MM/yyyy"), typeof(DateTime));

                grid1[i + 2, 2] = new SourceGrid.Cells.Cell(Convert.ToInt32(_ds.Tables[0].Rows[i]["SalaryFund_BHYTEmployee"]) + "\n" + Convert.ToInt32(_ds.Tables[0].Rows[i]["SalaryFund_BHXHEmployee"]), typeof(int));
                grid1[i + 2, 3] = new SourceGrid.Cells.Cell(Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHYTAmount"]).ToString("#,##0") + "\n" + Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHXHAmount"]).ToString("#,##0"), typeof(decimal));
                grid1[i + 2, 3].View.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleRight;
                grid1[i + 2, 4] = new SourceGrid.Cells.Cell(Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHYTHaveToPaid"]).ToString("#,##0") + "\n" + Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHXHHaveToPaid"]).ToString("#,##0"), typeof(decimal));

                if (Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHYTIncrease"]) == 0)
                {
                    if (Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHXHIncrease"]) == 0)
                        grid1[i + 2, 5] = new SourceGrid.Cells.Cell("" + "\n", typeof(string));
                    else
                        grid1[i + 2, 5] = new SourceGrid.Cells.Cell("" + "\n" + Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHXHIncrease"]).ToString("#,##0"), typeof(string));
                }
                else
                {
                    if (Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHXHIncrease"]) == 0)
                        grid1[i + 2, 5] = new SourceGrid.Cells.Cell(Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHYTIncrease"]).ToString("#,##0") + "\n" + "", typeof(decimal));
                    else
                        grid1[i + 2, 5] = new SourceGrid.Cells.Cell(Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHYTIncrease"]).ToString("#,##0") + "\n" + Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHXHIncrease"]).ToString("#,##0"), typeof(decimal));
                }

                if (Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHYTDecrease"]) == 0)
                {
                    if (Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHXHDecrease"]) == 0)
                        grid1[i + 2, 6] = new SourceGrid.Cells.Cell("" + "\n", typeof(string));
                    else
                        grid1[i + 2, 6] = new SourceGrid.Cells.Cell("" + "\n" + Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHXHDecrease"]).ToString("#,##0"), typeof(string));
                }
                else
                {
                    if (Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHXHDecrease"]) == 0)
                        grid1[i + 2, 6] = new SourceGrid.Cells.Cell(Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHYTDecrease"]).ToString("#,##0") + "\n" + "", typeof(decimal));
                    else
                        grid1[i + 2, 6] = new SourceGrid.Cells.Cell(Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHYTDecrease"]).ToString("#,##0") + "\n" + Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHXHDecrease"]).ToString("#,##0"), typeof(decimal));
                }

                if (Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHYTSum"]) == 0)
                {
                    if (Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHXHSum"]) == 0)
                        grid1[i + 2, 7] = new SourceGrid.Cells.Cell("" + "\n", typeof(decimal));
                    else
                        grid1[i + 2, 7] = new SourceGrid.Cells.Cell("" + "\n" + Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHXHSum"]).ToString("#,##0"), typeof(decimal));
                }
                else
                {
                    if (Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHXHSum"]) == 0)
                        grid1[i + 2, 7] = new SourceGrid.Cells.Cell(Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHYTSum"]).ToString("#,##0") + "\n", typeof(decimal));
                    else
                        grid1[i + 2, 7] = new SourceGrid.Cells.Cell(Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHYTSum"]).ToString("#,##0") + "\n" + Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHXHSum"]).ToString("#,##0"), typeof(decimal));
                }

                if (Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHYTPaidAmount"]) == 0)
                {
                    if (Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHXHPaidAmount"]) == 0)
                        grid1[i + 2, 8] = new SourceGrid.Cells.Cell("" + "\n", typeof(string));
                    else
                        grid1[i + 2, 8] = new SourceGrid.Cells.Cell("" + "\n" + Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHXHPaidAmount"]).ToString("#,##0"), typeof(string));
                }
                else
                {
                    if (Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHXHPaidAmount"]) == 0)
                        grid1[i + 2, 8] = new SourceGrid.Cells.Cell(Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHYTPaidAmount"]).ToString("#,##0") + "\n", typeof(decimal));
                    else
                        grid1[i + 2, 8] = new SourceGrid.Cells.Cell(Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHYTPaidAmount"]).ToString("#,##0") + "\n" + Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHXHPaidAmount"]).ToString("#,##0"), typeof(decimal));
                }


                if (Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHYTThua"]) == 0)
                {
                    if (Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHXHThua"]) == 0)
                        grid1[i + 2, 9] = new SourceGrid.Cells.Cell("" + "\n", typeof(string));
                    else
                        grid1[i + 2, 9] = new SourceGrid.Cells.Cell("" + "\n" + Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHXHThua"]).ToString("#,##0"), typeof(decimal));
                }
                else
                {
                    if (Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHXHThua"]) == 0)
                        grid1[i + 2, 9] = new SourceGrid.Cells.Cell(Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHYTThua"]).ToString("#,##0") + "\n", typeof(decimal));
                    else
                        grid1[i + 2, 9] = new SourceGrid.Cells.Cell(Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHYTThua"]).ToString("#,##0") + "\n" + Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHXHThua"]).ToString("#,##0"), typeof(decimal));
                }

                if (Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHYTThieu"]) != 0)
                {
                    if (Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHXHThieu"]) != 0)
                        grid1[i + 2, 10] = new SourceGrid.Cells.Cell(Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHYTThieu"]).ToString("#,##0") + "\n" + Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHXHThieu"]).ToString("#,##0"), typeof(decimal));
                    else
                        grid1[i + 2, 10] = new SourceGrid.Cells.Cell(Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHYTThieu"]).ToString("#,##0") + "\n", typeof(decimal));
                }
                else
                {
                    if (Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHXHThieu"]) != 0)
                        grid1[i + 2, 10] = new SourceGrid.Cells.Cell("" + "\n" + Convert.ToDecimal(_ds.Tables[0].Rows[i]["SalaryFund_BHXHThieu"]).ToString("#,##0"), typeof(decimal));
                    else
                        grid1[i + 2, 10] = new SourceGrid.Cells.Cell("" + "\n", typeof(string));
                }

            }
            grid1.AutoStretchColumnsToFitWidth = true;
            grid1.AutoSizeCells();
            _loadedData = true;

        }

        private class MyHeader : SourceGrid.Cells.ColumnHeader
        {
            public MyHeader(object value)
                : base(value)
            {
                //1 Header Row
                SourceGrid.Cells.Views.ColumnHeader view = new SourceGrid.Cells.Views.ColumnHeader();
                view.Font = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold);
                view.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;
                View = view;
                AutomaticSortEnabled = false;
            }
        }

        private void PageIndex()
        {
            totalPage = itemCount % pageSize > 0 ? (itemCount / pageSize) + 1 : (itemCount / pageSize);
            if (totalPage == 0)
                lblPageIndex.Text = "0" + "/" + totalPage.ToString();
            else
                lblPageIndex.Text = (currPage + 1).ToString() + "/" + totalPage.ToString();
        }

        private void btnOpenBook_Click(object sender, EventArgs e)
        {
            if (!listRole.Create)
            {
                MessageBox.Show(UpdateUI.GetString("Bạn không có quyền mở sổ"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            _month = Convert.ToInt32(cboMonth.Text);
            int temptYear;
            if (Int32.TryParse(cboYear.Text, out temptYear))
                _year = temptYear;

            _date = cboMonth.Text;

            _wcfSalaryFund = Service.SalaryFund();
            _wcfSalary = Service.Salary();
            _SalaryFundInfo = new SalaryFundInfo();
            _SalaryFundInfo.Month = DateTime.ParseExact(_date + "/" + _year.ToString(), "MM/yyyy", null);

            DataTable dt1 = _wcfSalaryFund.SalaryFund_GetDate(Program.strBranchBHXH).Tables[0];
            for (int i = 0; i < dt1.Rows.Count; i++)
            {
                if (DateTime.Compare(_SalaryFundInfo.Month, Convert.ToDateTime(dt1.Rows[i]["SalaryFund_Month"])) == 0)
                {
                    MessageBox.Show("Bạn đã mở sổ tháng này rồi!", UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }

            wcfParameter = Service.Parameter();
            _SocialInc = Convert.ToDecimal(wcfParameter.Parameter_GetByName("SocialInsurancePercent").Value) / 100 + Convert.ToDecimal(wcfParameter.Parameter_GetByName("SocialInsurancePercentLabour").Value) / 100;
            _MedicalInc = Convert.ToDecimal(wcfParameter.Parameter_GetByName("MedicalInsurancePercent").Value) / 100 + Convert.ToDecimal(wcfParameter.Parameter_GetByName("MedicalInsurancePercentLabour").Value) / 100;

            DataTable dt = _wcfSalary.Salary_GetSalaryFund(_month, _year).Tables[0];
            DataTable dtSa = _wcfSalary.Salary_CountEmployee(Convert.ToInt32(_month), Convert.ToInt32(_year)).Tables[0];
            if (dt.Rows[0]["MedicalSalary"] == DBNull.Value)
                dt.Rows[0]["MedicalSalary"] = 0;
            if (dt.Rows[0]["SocialSalary"] == DBNull.Value)
                dt.Rows[0]["SocialSalary"] = 0;
            if (dt.Rows[0]["TotalSalaryFund"] == DBNull.Value)
            {
                MessageBox.Show("Tháng này chưa tính lương!", UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            else
            {
                _SalaryFundInfo.BHYT_Amount = Convert.ToDecimal(dt.Rows[0]["MedicalSalary"]);
                _SalaryFundInfo.BHXH_Amount = Convert.ToDecimal(dt.Rows[0]["SocialSalary"]);

                _SalaryFundInfo.BHYT_HaveToPaid = _SalaryFundInfo.BHYT_Amount * _MedicalInc;
                _SalaryFundInfo.BHXH_HaveToPaid = _SalaryFundInfo.BHXH_Amount * _SocialInc;

                _SalaryFundInfo.BHYT_Employee = Convert.ToInt32(dtSa.Rows[0]["EmployeeMedical"]);
                _SalaryFundInfo.BHXH_Employee = Convert.ToInt32(dtSa.Rows[0]["EmployeeSocial"]);
            }

            //Insert:
            if (!listRole.Create)
            {
                MessageBox.Show(UpdateUI.GetString("khongcoquyenthemmoi"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            _SalaryFundInfo.ID = _wcfSalaryFund.SalaryFund_Insert(_SalaryFundInfo);
            if (_SalaryFundInfo.ID > 0)
            {
                Program.taskbarNotifier.Show(UpdateUI.GetString("thongbao"), UpdateUI.GetString("capnhatthanhcong"), UIParamater.TIME_MOVE_UP, UIParamater.TIME_SHOW, UIParamater.TIME_MOVE_DOWN);
                LoadData();
            }
            else
                MessageBox.Show(UpdateUI.GetString("capnhatkhongthanhcong"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
        }

        private void btnDel_Click(object sender, EventArgs e)
        {
            if (dgvList.SelectedRows.Count > 0)
            {
                if (!listRole.Delete)
                {
                    MessageBox.Show(UpdateUI.GetString("khongcoquyenxoa"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                SalaryFundID = Convert.ToInt32(dgvList.CurrentRow.Cells["SalaryFund_ID"].Value);
                if (MessageBox.Show(UpdateUI.GetString("bancochacchanxoa"), UIParamater.TitleProject, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    if (_wcfSalaryFund.SalaryFund_Delete(SalaryFundID))
                    {
                        Program.taskbarNotifier.Show(UIParamater.TitleProject, UpdateUI.GetString("xoathanhcong"), UIParamater.TIME_MOVE_UP, UIParamater.TIME_SHOW, UIParamater.TIME_MOVE_DOWN);
                        LoadData();
                    }
                    else
                    {
                        MessageBox.Show(UpdateUI.GetString("xoakhongthanhcong"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
        }

        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (dgvList.SelectedRows.Count > 0)
            {
                if (listRole.Update || listRole.View)
                {
                    SalaryFundID = Convert.ToInt32(dgvList.SelectedRows[0].Cells["SalaryFund_ID"].Value);
                    Form f = new frmSalaryFundInfo(SalaryFundID, listRole);
                    if (f.ShowDialog(this) == DialogResult.OK)
                    {
                        LoadData();
                    }
                }
                else
                    MessageBox.Show(UpdateUI.GetString("khongcoquyenxem"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }

        private void btnFisrt_Click(object sender, EventArgs e)
        {
            currPage = 0;
            LoadData();
        }

        private void btnNext_Click(object sender, EventArgs e)
        {
            totalPage = itemCount % pageSize > 0 ? (itemCount / pageSize) + 1 : (itemCount / pageSize);
            if (totalPage > 0 && currPage != totalPage - 1)
                currPage++;
            LoadData();
        }

        private void btnPrevious_Click(object sender, EventArgs e)
        {
            if (currPage != 0)
                currPage--;
            LoadData();
        }

        private void btnLast_Click(object sender, EventArgs e)
        {
            totalPage = itemCount % pageSize > 0 ? (itemCount / pageSize) + 1 : (itemCount / pageSize);
            if (totalPage != 0)
                currPage = totalPage - 1;
            LoadData();
        }

        private void dgvList_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            btnEdit_Click(null, null);
        }

        private void frmSalaryFundList_KeyUp(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
                case Keys.Escape:
                    this.Dispose();
                    this.Close();
                    break;
                case Keys.F2:
                    btnOpenBook_Click(null, null);
                    break;
                case Keys.F3:
                    btnEdit_Click(null, null);
                    break;
                case Keys.Delete:
                    btnDel_Click(null, null);
                    break;
            }
        }

        private void btnCloseBook_Click(object sender, EventArgs e)
        {
            if (!listRole.Update)
            {
                MessageBox.Show(UpdateUI.GetString("khongcoquyencapnhat"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            string sql = "SELECT SalaryFund_ID, SalaryFund_BHYTAmount,SalaryFund_BHXHAmount,SalaryFund_BHYTHaveToPaid,SalaryFund_BHXHHaveToPaid FROM HRM_SalaryFund WHERE SalaryFund_Month = (SELECT MAX(SalaryFund_Month) FROM HRM_SalaryFund)";
            wcfMainService = Service.MainService();
            DataTable dt = wcfMainService.Query(sql).Tables[0];
            SalaryFundID = Convert.ToInt32(dt.Rows[0]["SalaryFund_ID"]);
            Form f = new frmSalaryFundInfo(SalaryFundID, listRole);
            if (f.ShowDialog(this) == DialogResult.OK)
            {
                LoadData();
            }
        }

        private void cboMonth_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_loadedData)
            {
                LoadData();
            }
        }

        private void cboYear_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_loadedData)
            {
                LoadData();
            }
        }

        private void frmSalaryFundList_Activated(object sender, EventArgs e)
        {
            LoadLanguage();
            if (grid1.Columns.Count > 0)
            {
                grid1[0, 0] = new MyHeader(UpdateUI.GetString("quy"));
                grid1[0, 0].RowSpan = 2;
                grid1[0, 1] = new MyHeader(UpdateUI.GetString("thang"));
                grid1[0, 1].RowSpan = 2;
                grid1[0, 2] = new MyHeader(UpdateUI.GetString("doichieubhxh"));
                grid1[0, 2].ColumnSpan = 6;
                grid1[1, 2] = new MyHeader(UpdateUI.GetString("laodong"));
                grid1[1, 3] = new MyHeader(UpdateUI.GetString("tongquyluong"));
                grid1[1, 4] = new MyHeader(UpdateUI.GetString("phaithu"));
                grid1[1, 5] = new MyHeader(UpdateUI.GetString("dieuchinhtang"));
                grid1[1, 6] = new MyHeader(UpdateUI.GetString("dieuchinhgiam"));
                grid1[1, 7] = new MyHeader(UpdateUI.GetString("tongcong"));
                grid1[0, 8] = new MyHeader(UpdateUI.GetString("dathu"));
                grid1[0, 8].RowSpan = 2;
                grid1[0, 9] = new MyHeader(UpdateUI.GetString("chuyensang"));
                grid1[0, 9].ColumnSpan = 2;
                grid1[1, 9] = new MyHeader(UpdateUI.GetString("conthua"));
                grid1[1, 10] = new MyHeader(UpdateUI.GetString("thieu"));
            }
        }
    }
}

